package com.ojoin.trade.t0loan_core.utils.ftp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.ojoin.trade.common.constdef.IConstDef;
import com.ojoin.trade.common.utils.TimeUtils;
import com.ojoin.trade.t0loan_core.web.service.FtpFileBaseService;

/**
 * 连接FTP，获取pos交易文件供T+0放款
 * @author guoting
 *
 */
@Component
public class SFtpCreditThead implements Runnable {
	
	@Autowired
	private FtpFileBaseService ftpService;
	
	public void run() {
		SFtpUtils ftp = new SFtpUtils(
				IConstDef.FTP_OUT_IP, IConstDef.FTP_T0_USERNAME, 
				IConstDef.FTP_T0_PASSWORD, IConstDef.FTP_OUT_PORT);
//		String localPath = this.getClass().getResource("/credit").getPath();
		String localPath = "C://";
		String remotePath = "/download/" + TimeUtils.getShortCurDate() + "/";
		
		String remoteFileSufFix= "loan.txt";
		ftp.connect();

//		ftp.uploadFile(remotePath, "test22.txt", localPath, "recon1.txt");
//		ftp.bacthUploadFile(remotePath,localPath,true);
//		ftp.downloadFile(remotePath, remoteFile, localPath, remoteFile);
		ftp.batchDownLoadFile(remotePath, localPath, remoteFileSufFix, false);

		ftp.disconnect();
		System.exit(0);
			
	}

	public static void main(String[] args) {
		Thread t = new Thread(new SFtpCreditThead(), "CreditThread");
		t.start();
	}
}
